<?php

namespace app\api\controller;

use app\common\lib\Param;
use app\common\lib\Show;
use app\common\lib\Str;
use app\Request;
use think\facade\Cache;

class Links extends ApiBase
{

    public function index(){
        $limit = input("limit", 0, "intval");
        $category_id = input("category_id", 0, "intval");

        $linksBis = new \app\common\business\Links();
        $map = [];
        $category_id != 0 && $map[] = ['category_id','=',$category_id];

        try {
            $list = $linksBis->getListByWhereWithLimit($map,$limit,'sort desc,id asc');
        } catch (\Exception $e) {
            return Show::error([], $e->getMessage(), $e->getCode());
        }

        return Show::success($list);
    }
}